var jsonFile = require('jsonfile')
var fileName = 'et.json'
const axios = require('axios')
var jsonData = jsonFile.readFileSync(fileName)
const qs = require('qs')

const phone = jsonData.phone
const pwd = jsonData.pwd
const token = jsonData.token
const pay_pwd = jsonData.pay_pwd
const goods = jsonData.goods
var requestArray = []

const instance = axios.create({
  credentials: true,
  baseURL: 'https://nft.etqfnb.com',
  headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36' }
})
instance.defaults.headers['Content-Type'] = 'application/json;'
instance.defaults.headers['token'] = token





pushList()


// 商品列表填充
function pushList() {
  setInterval(() => {
    instance.post('/api/collectionissue/create', { collection_issue_id: 239 }).then(res => {
      if (res.data.code == 1) {
        let orderId = res.data.data.id
        console.log(res.data)
        axios.post('https://open.feishu.cn/open-apis/bot/v2/hook/9234b14f-e535-41e2-98dd-309f1fd2b580', { "msg_type": "text", "content": { "text": "ET锁单成功,请上号支付!!!" + orderId } })
        instance.post('/api/collectionissue/pay', {
          order_sn: orderId,
          payment: "sdpay",
          security: "",
          user_card_id: null
        }).then(res => {
          if (res.data.code == 1) {
            console.log(res.data.data.url)
            let url = res.data.data.url
            axios.post('https://open.feishu.cn/open-apis/bot/v2/hook/9234b14f-e535-41e2-98dd-309f1fd2b580', { "msg_type": "text", "content": { "text": "ET提取链接成功,请支付!!!" + url } })
          }
        }).catch(err => {
          console.log(err.response)
        })
      } else {
        console.log(res.data)
      }
    }).catch(err => {
      console.log(err.response)
    })
  }, 200)
}